ProjectName.modules.Preference= {
    init: function () {
        this.formValidation();
    } ,
    formValidation : function () {
        $.validator.addMethod("paging_non_zero", function(value) {
            if (parseInt(value) > 0) {
                return true;
            }
        }, 'Paging limit should be greater than zero.');

        var container = $('div.pageerrorcontainer-validator');
	
        $("#preferencefrm").validate({
            errorContainer: container,
            errorLabelContainer: $("div.error-iterator", container),
            wrapper: 'div',
            rules: {
                company_name: "required",
                company_url: {
                    required: true,
                    url: true
                },
                admin_email: {
                    required: true,
                    email: true
                },
                paging_limit : {
                    required: true,
                    digits: true,
                    paging_non_zero : true
                } ,
                default_price : {
                    required: true,
                    number: true
                }
            },
            messages: {
                company_name: "Company name shouldnot be blank.",
                company_url: {
                    required: "Company url shouldnot be blank.",
                    url: "Company url is not valid url"
                },
                admin_email: {
                    required: "Admin Email address shouldnot be blank.",
                    email: "Admin Email address is not valid."
                },
                paging_limit: {
                    required: "Please enter paging limit for each page.",
                    digits: "Please enter only valid numeric value for paging."
                }
            }
        });
    }
}
